// mypage/userName/userName.js
var util=require("../../utils/util");

Page({
  /*页面的初始数据*/
  data: {
    val: ''
  },
  /*生命周期函数--监听页面加载*/
  onLoad: function (options) {
    var that=this;
    if(options.text!=null){
      that.setData({val:options.text})
    }
  },
  input_text:function(e){
    this.setData({val: e.detail.value})
  },
  del_val:function(){
    var that = this,val=that.data.val;
    if(val){
      that.setData({val:''})
    }
  },
  // 保存
  confirm_text:function(){
    var that = this,val=that.data.val,testSpace = /^[ ]*$/g;
    var pages = getCurrentPages();
    var prevPage = pages[pages.length - 2];
    if(val.length<2||testSpace.test(val)){
      util.page_show_toast('请输入个人昵称',2000)
    }else{
      prevPage.setData({text1: util.removeAllSpace(val)})
      wx.navigateBack({
        delta: 1
      })
    }
  },
})